package pacman;

import javax.microedition.lcdui.Display;
import jmunit.framework.cldc11.*;
import jmunit.framework.cldc11.TimedMeasurement;

public class pacmanTestCase extends TestCase{
	
	private SSCanvas PacmanGameScreen;
	private Thread gameThread,pacmanSpriteThread;
	private Display display; 
	private AnimatedSprite pacmanSprite;
	
	public void tearDown()
	{
		this.removeAllPerformanceMeasurements();
		PacmanGameScreen.stop();
	}
	
	public void setUp()
	{
		System.out.println("entro al metodo setUp()");
		display=Display.getDisplay(this); 
		this.PacmanGameScreen = new SSCanvas();
	}
	
	public pacmanTestCase()
	{
		super(6,"Performance test vrs 75 ms");
	}
	
	public void testSpeedRequirements() throws InterruptedException
	{
		//this.addPerformanceMeasurement(new TimedMeasurement(50,0));
		//Thread.sleep(50);
		
	}
	
	public void test(int testNumber) throws Throwable
	{
		long testTime = 150;
		switch(testNumber)
		{
		case 0:
			testPerformanceLevel(testTime,testNumber);
			break;
		case 1:
			testPerformanceLevel(testTime,testNumber);
			break;
		case 2:
			testPerformanceLevel(testTime,testNumber);
			break;
		case 3:
			testPerformanceLevel(testTime,testNumber);
			break;
		case 4:
			testPerformanceLevel(testTime,testNumber);
			break;
		case 5:
			testPerformanceLevel(testTime,testNumber);
			break;
		default:
			fail("No such test");	
		}
	}
	
	public void testPerformanceLevel(long time, int level) throws InterruptedException
	{
		PacmanGameScreen = new SSCanvas();
		this.PacmanGameScreen.setLevel(level);
		PacmanGameScreen.startTest();
		Thread.sleep(70);
		assertEquals(0, PacmanGameScreen.getDurationOfLoop());
	}	
}
